<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>白名单|黑名单</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>
	    <table class="layui-table" id="NameList" lay-filter="NameList"></table>
	    
	    <script type="text/html" id="toolbar">
          <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="addData">增加</button>
          </div>
        </script>
	    
	    <script type="text/html" id="BlockType">
          {{#  if(d.BlockType == 1){ }}
                  <span class="layui-badge" style="background:#130c0e">IP黑名单</span>
          {{#  }else if(d.BlockType == 2){ }}
                  <span class="layui-badge" style="background:#130c0e">设备黑名单</span>
          {{#  }else if(d.BlockType == 3){ }}
                  <span class="layui-badge" style="background:#007947">IP白名单</span>
          {{#  }else if(d.BlockType == 4){ }}
                  <span class="layui-badge" style="background:#007947">设备白名单</span>
          {{#  }else if(d.BlockType == 5){ }}
                  <span class="layui-badge" style="background:#007947">账号白名单</span>
          {{#  } }}
        </script>
        
        <script type="text/html" id="barDemo">
          <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>
	    
	    <script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script>
		    layui.use(['layer','form','table'],function(){
		    	var layer = layui.layer,
		    	    form  = layui.form,
		    	    table = layui.table;
		    	
		    	layer.config({
					extend: 'MySkin/style.css'
				});
		    	
		    	table.render({
		    		elem:'#NameList',
		    		url:'admin/SpecialCompetenciesList',
		    		toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
		    		defaultToolbar: [],  //隐藏右边工具栏
		    		method:'post',
		    		title:'渠道',
		    		height: 'full-200',
		    		skin: 'row',
		    		even: true,//开启隔行背景
		    		id:'AllTable',
		    		cellMinWidth : 100,
		    		cols:[[
		    			{field:'Id',title:'Id'},
		    			{field:'BlockType',title:'类型',style:'color:blue',templet:'#BlockType'},
		    			{field:'BlockValue',title:'对应的值 ',style:'color:blue'},
		    			{field:'BlockReason',title:'添加原因',style:'color:#00a6ac'},
		    			{field:'BlockOperator',title:'添加人 ',style:'color:#840228'},
		    			{field:'BlockTime',title:'添加时间 ',style:'color:#00ae9d'},
		    			{fixed: 'right',title:'操作',width:200,toolbar:'#barDemo'}
		    			]],
		    			page : false,//分页
						response : {
							statusCode : 200
						//重新规定成功的状态码为 200，table 组件默认为 0
						},
						parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code" : res.status, //解析接口状态
								"msg" : res.message, //解析提示文本
								"count" : res.count, //解析数据长度
								"data" : res.data
							//解析数据列表
							};
						}
		    	});
		    	
		    	
		    	//监听头工具栏事件
		    	table.on('toolbar(NameList)',function(obj){
		    		switch(obj.event){
		    		case 'addData':
		    			var tabledata = JSON.stringify(layui.table.cache.AllTable);
		    			var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['650px', '350px'],
							title: '增加账号名单',
							skin: 'layer-ext-yourskin',
							content: 'admin/toaddnamelist',
							success: function(layero,index,resp) {
								var body = layer.getChildFrame("body", index);
								body.find("#receiveData").val(tabledata);
							},error:function(){
								
							},yes:function(index,layero){
								var obj = $(layero).find("iframe")[0].contentWindow;
								console.log(index);
							}
						})
		    			
		    		break;
		    		}
		    	});
		    	
		    	
		    	//监听行工具事件
		    	table.on('tool(NameList)',function(obj){
		    		console.log(obj)
		    		var data = obj.data;
		    		if(obj.event === 'del'){
		    			var id = data.Id;
	    				var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['1000px', '500px'],
							title: "查看玩家信息",
							skin: 'layer-ext-yourskin',
							content: 'admin/toremovenamelist',
			    			success:function(rsp){
			    				var body = layer.getChildFrame("body", index);
								body.find(".zid").val(id);
			    			},error:function(){
			    				layer.msg("删除失败",{icon:2});
			    			}
	    			});
		    	}
		    });
		    	
		    });
		</script>
    </body>
</html>